package com.gtja.beoms.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gtja.beoms.dto.QwCustomerDTO;
import com.gtja.beoms.pojo.QwCustomer;
import io.lettuce.core.dynamic.annotation.Param;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.session.RowBounds;
import org.springframework.dao.DataAccessException;

import java.util.List;
import java.util.Map;

/**
 * 外部客户信息接口
 *
 * @author Li
 */
@Mapper
public interface QwCustomerDao extends BaseMapper<QwCustomer> {


    /**
     * 添加外部客户信息
     *
     * @param qwCustomer
     * @return
     * @throws DataAccessException
     */
    int insertCustom(QwCustomer qwCustomer) throws DataAccessException;

    /**
     * 查询外部客户信息
     *
     * @param params
     * @return
     * @throws DataAccessException
     */
    QwCustomer getCustom(Map<String, String> params) throws DataAccessException;

    /**
     * 查询外部客户信息
     *
     * @param params
     * @return
     * @throws DataAccessException
     */
    List<QwCustomer> getCustomList(Map<String, String> params) throws DataAccessException;

    /**
     * 更新外部客户信息
     *
     * @param qwCustomer
     * @return
     * @throws DataAccessException
     */
    int updateCustom(QwCustomer qwCustomer) throws DataAccessException;

    /**
     * 删除外部客户信息
     *
     * @param params
     * @return
     * @throws DataAccessException
     */
    int deleteCustom(Map<String, Object> params) throws DataAccessException;


    /**
     * 获取客户列表信息
     *
     * @param param
     */
    List<QwCustomerDTO> getCustomerInfoList(RowBounds rowBounds, Map<String, Object> param);

    /**
     * 获取客户列表总数
     *
     * @param param
     */
    int getCustomerInfoListCount(Map<String, Object> param);

    /**
     * 获取客户信息详情
     *
     * @param param
     */
    QwCustomerDTO getCustomerInfo(Map<String, Object> param);

    /**
     * 获取员工的指定类型的客户数量
     *
     * @param dateList
     */
    List<Integer> getCustomerTotalByUser(@Param("list") List<Map<String, Object>> dateList);


    /**
     * 获取去重后的指定类型客户数量
     *
     * @param param
     */
    int getCustomerDistinctTotalByType(Map<String, Object> param);


    /**
     * 获取去重后的客户id和客户名字
     */
    QwCustomer getDistinctCustomInfo(String corpId, String custQwId) throws DataAccessException;

    /**
     * 批量插入客户
     *
     * @param qwCustomInfos
     */
    void batchInsertQwCustom(@org.apache.ibatis.annotations.Param("qwCustomInfos") List<QwCustomer> qwCustomInfos);

    /**
     * 根据userQwId查询userName
     * @param fromId 用户id
     * @param corpId 企微id
     * @return
     */
    String selectUserNameById(@Param("fromId") String fromId, @Param("corpId") String corpId);
}
